package GUI;

import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Polygon;
import java.awt.geom.AffineTransform;
import java.awt.geom.Line2D;

import Data.Relation;
import Data.State;

public class DrawGraphics {
	
	public static void drawFinalState(Graphics graph, String stateName,int x,int y){
		graph.drawOval(x,y,50,50);
		graph.drawOval(x-3,y-3,56,56);
		graph.drawString(stateName,x+20,y+30);
	}
	
	public static void drawState(Graphics graph, String stateName,int x,int y){
		graph.drawOval(x,y,50,50);
		graph.drawString(stateName,x+20,y+30);
	
	}
	
	public static void drawInitialState(Graphics graph, String stateName,int x,int y){
		graph.drawOval(x,y,50,50);
		 int xpoints[] = {x-20, x-20, x};
		    int ypoints[] = {y, y+40, y+20};
		    int npoints = 3;
		    graph.drawString(stateName,x+20,y+30);
		graph.drawPolygon(xpoints,ypoints,npoints);
	}
	
	public static void drawInitialFinalState(Graphics graph, String stateName,int x,int y){
		graph.drawOval(x,y,50,50);
		graph.drawOval(x-3,y-3,56,56);
		 int xpoints[] = {x-20, x-20, x};
		    int ypoints[] = {y, y+40, y+20};
		    int npoints = 3;
		graph.drawPolygon(xpoints,ypoints,npoints);
		graph.drawString(stateName,x+20,y+30);
	}
	
	public static void drawRelation (Graphics graph,Relation relation, State sourceState, State destinationState, int level){
		if(sourceState.getStateName().equalsIgnoreCase(destinationState.getStateName())){
			
			
			graph.drawArc(sourceState.getX()+12,sourceState.getY()-30, 20,70,0,180);
			graph.drawString(relation.getTransitionValue(),sourceState.getX()+25,sourceState.getY()-30);
			graph.drawOval(sourceState.getX()+25,sourceState.getY()-30,10,10);
		}
		else
		{
			
			graph.drawLine(sourceState.getX()+15, sourceState.getY()+25,destinationState.getX(), destinationState.getY());
			int mediumX =(int) ((sourceState.getX()+15+destinationState.getX()+15)/2);
			int mediumY =(int) ((sourceState.getY()+25+destinationState.getY()+25)/2);
			graph.drawString(relation.getTransitionValue(),destinationState.getX(), destinationState.getY());
			graph.drawOval(destinationState.getX(), destinationState.getY(),10,10);
		}
		
		
	}

}
